using System;
using System.Collections.Generic;
using System.Text;

namespace CommandPatternApp
{
    public class CutCmd : UndoableCmd
    {
        private int _selStart;
        private string _selText;

        public CutCmd(TextEditor editor, CmdFactory factory)
            : base(editor, factory)
        {
            _selStart = editor.SelectionStart;
            _selText = editor.SelectedText;
        }

        public override string Name
        {
            get { return "Cut"; }
        }

        public override void Execute()
        {
            CutCmd cmd = _factory.CutCmd();
            _editor.Cut(cmd);
        }

        public override void Undo()
        {
            _editor.UndoCut(_selStart, _selText);
        }
    }
}
